const myArray = [1, 2, [3, 4, 5, [6, [7]]], 8, [9]]

// flat

// 扁平化一层
const flatArray1 = myArray.flat()
console.log(flatArray1); //[ 1, 2, 3, 4, 5, [ 6, [ 7 ] ], 8, 9 ]

// 扁平化两层
const flatArray2 = myArray.flat(2)
console.log(flatArray2); //[1,2, 3,4,5, 6,[ 7 ], 8, 9]

// 扁平化为一维数组
const flatArray3 = myArray.flat(3)
console.log(flatArray3); //[1, 2, 3, 4, 5,6, 7, 8, 9]

const flatArray4 = myArray.flat(Infinity)
console.log(flatArray4);
